/*
 * @Author: baoyiwen 511530203@qq.com
 * @Date: 2025-04-25 15:36:58
 * @LastEditors: wangjing 1173862626@qq.com
 * @LastEditTime: 2025-06-06 11:11:1
 * @FilePath: \neilao-mobile\src\api\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import axios from 'axios'
import { http, axiosInstance } from '../utils/request'
import sm from '../utils/sm-crypto'
const { VITE_BASE_URL_POST, MODE } = import.meta.env

const BASE_URL = `/early-warning-web/zyAuthApi/auth/b/getPicCaptcha`
const BASE_LOGIN_URL = `/command-centre-mobile/zyAuthApi/auth/b/doLogin`
const BASE_USER_INFO_URL = '/system-maintain/zyAuthApi/auth/b/getLoginUser'
const BASE_TOKEN = `/system-maintain/zyAuthApi/auth/b/zzd/secretFree/doLogin`

// 判断是否是生产环境
const isProduction = MODE === 'production'

export const getPicCaptcha = () => {
  return http.get(`${isProduction ? BASE_URL : VITE_BASE_URL_POST + BASE_URL}`)
}
export const doLogin = (loginInfo) => {
  const body = { ...loginInfo }
  body.device = body.device || 'PC'
  body.password = sm.doSm2Encrypt(loginInfo.password)
  return http.post(
    `${isProduction ? BASE_LOGIN_URL : VITE_BASE_URL_POST + BASE_LOGIN_URL}`,
    body,
  )
}

export const getUserInfo = (token) => {
  return axios({
    url: `${isProduction ? BASE_USER_INFO_URL : VITE_BASE_URL_POST + BASE_USER_INFO_URL}`,
    method: 'get',
    headers: {
      token: token,
    },
  })
}

export const getTokenByCode = (code) => {
  return axios({
    url: `${VITE_BASE_URL_POST}${BASE_TOKEN}`,
    method: 'post',
    data: {
      authCode: code,
    },
  })
}
export const getDisposeList = (params, data) => {
  return http.post(`/cqwl/biz/work/workList`, data, {
    params,
  })
}
export const getWorkDetail = (id) => {
  return http.post(`/cqwl/biz/work/getWorkById/${id}`)
}
//处置反馈
export const feedback = (data) => {
  return http.post(`/cqwl/biz/work/feedback`, data)
}

export const getList = (ids) => {
  return axios({
    url: `/cqwl/biz/inspectionMatters/listByIds/${ids}`,
    method: 'get',
  })
}
export const getListYd = (data) => {
  return http.post(`/cqwl/re/work/listYd`, data)
}
//提交办结
export const completion = (data) => {
  return http.post(`/cqwl/biz/work/completion`, data)
}

// 获取响应工单列表
export const getResponseList = (params, data) => {
  return http.post(`/cqwl/re/work/listYd`, data, {
    params,
  })
}

// 获取响应工单详情
export const getResponseWordDetail = (id) => {
  return http.post(`/cqwl/re/work/todo/${id}`)
}
// 获取响应工单详情
export const getInspectionMatters = (id) => {
  return http.get(`/cqwl/biz/inspectionMatters/listByIds/${id}`)
}

// 获取响应工单详情
export const getWorkTimelineDetail = (id) => {
  return http.post(
    `/cqwl/operationLogQueryController/getWorkTimelineDetail?id=${id}`,
  )
}

// 确认响应
export const editWorkStatus = (data) => {
  return http.post(`/cqwl/re/work/editWorkStatus`, data)
}

// 上传
export const upload = (data) => {
  return http.post(`/cqwl/file/upload`, data)
}

// 确认到场
export const confirmAttendance = (data) => {
  return http.post(`/cqwl/biz/work/confirmAttendance`, data)
}

export const getDataToken = (token) => {
  return axios({
    url: `/cqwl/biz/baseplat/getToken/${token}`,
    method: 'get',
  })
}
// 是否在库，选择在库时，根据用户地区code获取点位列表
export const getPointPlus = (code) => {
  return http.post(`/cqwl/biz/yj/History/pointPlus/${code}`)
}

// 快处上报
export const speedinessReport = (data) => {
  return http.post(`/cqwl/biz/work/speedinessReport`, data)
}

// 根据等级获取处置情况
export const dangerClasses = (level) => {
  return http.post(`/cqwl/biz/work/dangerClasses/${level}`)
}
// 获取班组

export const getBzOptions = (data) => {
  return http.post(`/cqwl/re/yj/Class/findClass`, data)
}
